/**
 * Created by yuming619 on 2017/12/16.
 */
angular.module('service.mqhp', [
    "ngResource"
])
    .service('MsgmqhpService', MsgmqhpService);
MsgmqhpService.$inject = ['$q','$resource','CupboarlockService','IMSdkService'];
function MsgmqhpService($q,$resource,CupboarlockService,IMSdkService) {
    //开关锁服务
    this.update = function(data,success,error){
        var resource = $resource(mqhpurl + "chat/member");
        return resource.save({},data,success,error);
    };
    this.creatMqhp = function(uid,devid,success,error){
        var self = this;
        IMSdkService.init();//消息服务初始化
        CupboarlockService.getInfo(devid).$promise.then(function(data){
            //console.log(data);
            var chatMember = {
                "uid": uid,
                "privilege": 0,
                "chatid": data.chatid
                };
            //IMSdkService.login(data.topic);
            self.update(chatMember,function(){
                IMSdkService.login(data.topic);
            },error)
        },error)
    }
}